package org.hxzon.demo.scala.matchdemo

object GuardMatch {
  def process(input: Any) {
    input match {
      case (a: Int, b: Int) => println("(int,int)")
      case (a: Double, b: Double) => println("(double,double)")
      case msg: Int if (msg > 1000000) => println("int > 1000000")
      case msg: Int => println("int")
      case msg: String => println("string")
      case _ => printf("can't handle %s...\n", input)
    }
  }
  def main(args: Array[String]): Unit = {
    process((34.2, -159.3)) //(double,double)
    process(0) //int
    process(1000001) //int > 1000000
    process(2.2) //can't handle 2.2...
    process(2, 2.3) //can't handle (2,2.3)...
    process(List("hello", "hi")) //can't handle List(hello, hi)...
    process("Hi") //string
  }
}
